import java.util.ArrayList;
import java.util.concurrent.*;

public class TestCallable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService pool = Executors.newFixedThreadPool(10);
        ArrayList<Future> list = new ArrayList<Future>();
        for (int i = 0;i < 10;i++){
            Callable c = new MyCallable();
            Future f = pool.submit(c);//执行任务并获取Future对象
            list.add(f);
        }

        //关闭线程池
        pool.shutdown();
        //获取所有并发任务的运行结果
        for(Future f : list){
            System.out.println(f.get().toString());
        }
    }
}
